#pragma once
#include <iostream>
#include <string>
#include <memory>
#include "Socket.hpp"
#include<jsoncpp/json/json.h>
#include<functional>

using namespace SocketModule;
using namespace std;

class Request
{
    public:
    Request(){};
    Request(int x,int y,char oper):_x(x),_y(y),_oper(oper){}
    string Serialize(){
        Json::Value root;
        root["x"]=_x;
        root["y"]=_y;
        root["oper"]=_oper;
        Json::FastWriter writer;
        string s=writer.write(root);
        return s;
    }
    bool Deserialize(string& in){
        Json::Value root;
        Json::Reader reader;
        bool ok=reader.parse(in,root);
        if(ok)
        {
            _x=root["x"].asInt();
            _y=root["y"].asInt();
            _oper=root["oper"].asInt();
        }
        return ok;
    }
    ~Request(){}
    int X(){return _x;}
    int Y(){return _y;}
    int Oper(){return _oper;}

    private:
    int _x;
    int _y;
    char _oper;
};
class Response
{
    public:
    Response(){}
    Response(int result,int code):_result(result),_code(code)
    {}
    string Serialize(){}
    bool Deserialize(string& in){}
    ~Response(){}
    private:
    int _result;
    int _code;
};
class Protocal
{
    public:
    Protocal(){}
    void GerRequest(shared_ptr<Socket>&sock,InetAddr &client)
    {}
    ~Protocal(){}
    private:
    Request _req;
    Response _resp;
};